home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK1.toast / Development Kits (Disc 1) / AIAT 1.0.1 / Headers / Corpus / HFSCorpus.h next >
Encoding:
Text File  |  1997-09-11  |  4.6 KB  |  163 lines  |  [TEXT/CWIE]

  1. // HFSCorpus.h
  2. //    Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  3.  
  4. // a corpus implementation for Macintosh HFS files
  5.  
  6. #pragma once
  7. #ifndef HFSCorpus_h
  8. #define HFSCorpus_h
  9.  
  10. #pragma import on
  11.  
  12. #include "IACorpus.h"
  13.  
  14. //#pragma IA_BEGIN_IMPORTS
  15. #include <Types.h>
  16. //#pragma IA_END_IMPORTS
  17.  
  18. #pragma IA_BEGIN_EXPORTS
  19.  
  20. const uint32    HFSCorpusType = 'HFS0';
  21.  
  22. /// HFSVolumeInfo
  23.  
  24. class HFSVolumeInfo : public IAStorable {
  25. public:
  26.                 HFSVolumeInfo() : name(NULL) {}
  27.                 HFSVolumeInfo(short vRefNum);
  28.                 ~HFSVolumeInfo();
  29.  
  30.     
  31.     // methods to store a HFSVolumeInfo
  32.     IABlockSize    StoreSize() const;
  33.     void        Store(IAOutputBlock* output) const;
  34.     IAStorable*    Restore(IAInputBlock* input) const;
  35.     IAStorable*    DeepCopy() const;
  36.     
  37.     short GetVolumeRefNum() const {return vRefNum;}
  38.     StringPtr GetVolumeName() const {return name;}
  39.     long GetCreationDate() const {return creationDate;}
  40.  
  41.     void SetVolumeRefNum(short refNum) {vRefNum = refNum;}
  42.     void SetVolumeName(StringPtr vname) {name = vname;}
  43.     void SetCreationDate(long cDate) {creationDate = cDate;}
  44.  
  45. private:
  46.                 HFSVolumeInfo(short v, StringPtr n, long c) : vRefNum(v), name(n), creationDate(c) {}
  47.     short        FindVRefNum(const StringPtr name, long creationDate) const;
  48.  
  49.                 HFSVolumeInfo(HFSVolumeInfo&);    // don't define a copy constructor
  50.                 
  51.     short        vRefNum;                    // volume reference number (ephemeral)
  52.     StringPtr    name;                        // volume name (persistent)
  53.     long        creationDate;                // volume creation date (persistent)
  54.  
  55. };
  56.  
  57. IAExceptionCode        HFSVolumeNotFound = 'VCHV';
  58. IAExceptionCode        HFSError =             'VCHE';
  59.  
  60. class HFSCorpus : public IACorpus {
  61. public:    
  62.                 HFSCorpus(uint32 type = HFSCorpusType)
  63.                     : volumeInfos(NULL), volumeCount(0), IACorpus(type) {}
  64.                 ~HFSCorpus();
  65.  
  66.     // IACorpus methods
  67.     IADoc*        GetProtoDoc();
  68.     IADocText*    GetDocText(const IADoc* doc);
  69.     
  70.     // HFSCorpus-specific methods
  71.     unsigned short    GetVRefID(short vRefNum);
  72.     short            GetVRefNum(unsigned short vRefID);
  73.     
  74. protected:
  75.     IABlockSize    InitialSize();
  76.     void        Initializing(IAOutputBlock* output);
  77.     void        Opening(IAInputBlock* input);
  78.     IABlockSize    UpdateSize();
  79.     void        Updating(IAOutputBlock* output);
  80.  
  81.     void            DeleteVolumeInfos();
  82.  
  83.     void SetVolumeInfos (HFSVolumeInfo** vinfos) {volumeInfos = vinfos;}
  84.     void SetVolumeCount(short vCount) {volumeCount = vCount;}
  85.     
  86.     HFSVolumeInfo** GetVolumeInfos () const {return volumeInfos;}
  87.     short GetVolumeCount() const {return volumeCount;}
  88.  
  89. private:
  90.                 HFSCorpus(HFSCorpus&);        // don't define a copy constructor
  91.     HFSVolumeInfo** volumeInfos;            // array mapping from vRefID to HFSVolumeInfo
  92.     short            volumeCount;            // length of the array
  93.                 
  94.                 
  95. };
  96.  
  97. class HFSDoc : public IADoc {
  98. public:
  99.                 HFSDoc(HFSCorpus* corpus, short vRefNum, long dirID, const StringPtr name);
  100.                 HFSDoc() : fileName(NULL) {}
  101.     virtual        ~HFSDoc();
  102.  
  103.     IAStorable*    DeepCopy() const;
  104.     IABlockSize    StoreSize() const;
  105.     void        Store(IAOutputBlock* output) const;
  106.     IAStorable*    Restore(IAInputBlock* input) const;
  107.  
  108.     bool        LessThan(const IAOrderedStorable* neighbor) const;
  109.     bool        Equal(const IAOrderedStorable* neighbor) const;
  110.     
  111.     byte*        GetName(uint32 *length) const;
  112.     
  113.     void             SetVolumeRefID(unsigned short vrid) {vRefID = vrid;}
  114.     void             SetDirID(long dID) {dirID = dID;}
  115.     void             SetFileName(StringPtr name) {fileName = name;}
  116.     unsigned short     GetVolumeRefID() const {return vRefID;}
  117.     long             GetDirID() const {return dirID;}
  118.     StringPtr         GetFileName() const {return fileName;}
  119.     
  120.     
  121. protected:
  122.     void        DeepCopying(const IAStorable* source);
  123.     void        Restoring(IAInputBlock* input, const IAStorable* proto);
  124. private:
  125.                 HFSDoc(HFSDoc& fd);            // don't define a copy constructor
  126.     unsigned short    vRefID;                    // not a vRefNum! use as arg to GetVRefNum().
  127.     long            dirID;
  128.     StringPtr        fileName;                // alloated with IAMallocArraySized
  129.  
  130. };
  131.  
  132. class HFSDocText : public IADocText {
  133. public:
  134.                             HFSDocText() : refNum(0) {}
  135.                             HFSDocText(short vRefNum, long dirID, const StringPtr name);
  136.                             ~HFSDocText();
  137.     
  138.     uint32                    GetNextBuffer(byte* buffer, uint32 bufferLength);
  139.     IADocText*                DeepCopy() const;    
  140. protected:
  141.         void SetRefNum (short rNum) {refNum = rNum;}
  142.         void SetTheVolumeRefNum(short vrnum) {theVRefNum = vrnum;}
  143.         void SetTheDirID(long did) {theDirID = did;}
  144.         void SetTheFileName(StringPtr name) {theFileName = name;}
  145.         
  146.         short         GetRefNum () const {return refNum;}
  147.         short         GetTheVolumeRefNum() const {return theVRefNum;}
  148.         long         GetTheDirID() const {return theDirID;}
  149.         StringPtr     GetTheFileName() const {return theFileName;}
  150.         
  151. private:
  152.                             HFSDocText(HFSDocText&);    // don't define a copy constructor
  153.  
  154.     short                    refNum;
  155.     short                    theVRefNum;            
  156.     long                    theDirID;            
  157.     StringPtr                theFileName;        
  158. };
  159.  
  160. #pragma IA_END_EXPORTS
  161.  
  162. #pragma import reset
  163. #endif